package utils.pageutil;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
* @Author gwq
* @Description
* @Date 2023/4/18 20:28
* @Return
*/

public class MyPageHelper {

    public static void startPage(PageRequest pageRequest) {
        PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getPageSize());
    }

    public static PageResult getPageResult(List content) {
        PageInfo pageInfo = new PageInfo<>(content);
        PageResult pageResult = new PageResult();
        pageResult.setTotal(pageInfo.getTotal());
        pageResult.setContent(pageInfo.getList());
        pageResult.setPages(pageInfo.getPages());
        pageResult.setPageNum(pageInfo.getPageNum());
        pageResult.setPageSize(pageInfo.getPageSize());
        return pageResult;
    }

}
